package com.secxiot.common.constant;

/**
 * 上传文件类型枚举
 */
public enum FileEnum {
    NULL("",""),
    IMAGE("0000600001",".jpg|.jpeg|.png|.bmp|.tif|.gif|.pcx|.tga|.exif|.fpx|.svg|.psd|.cdr|.pcd|.dxf|.ufo|.eps|.ai|.raw|.wmf|.webp"),
    PDF("0000600002",".pdf"),
    WORD("0000600003",".doc|.docx"),
    EXCEL("0000600004",".xls|.xlsx"),
    TEXT("0000600005",".text"),
    ;
    public String code;
    public String value;

    FileEnum(String code, String value) {
        this.code = code;
        this.value = value;
    }

    public String getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public static FileEnum getByCode(String code){
        for (FileEnum fileEnum : FileEnum.values()) {
            if (fileEnum.getValue().contains(code.toLowerCase())) {
                return fileEnum;
            }
        }
        return NULL;
    }
}
